s="abcevaefegsgdghfdefavbdr"
dict1={}
for char in s:
    value=dict1.setdefault(char,0)
    dict1[char] += 1
print("元素\t个数")
order=[]
for k,v in dict1.items():
    if order==[] or order[-1][1]>v:
        order.append([k,v])
    elif order[0][1]<v:
        order.insert(0,[k,v])
    else:
        ledge=0
        redge=len(order)
        mid=redge//2
        while redge-ledge>1:
            if order[mid][1]>v:
                ledge=mid
            else:
                redge=mid
            mid=(redge+ledge)//2
        order.insert(redge,[k,v])
    print(k,v,sep="\t")
print("出现次数最多的三个元素为：",end="")
print(order[0][0],order[1][0],order[2][0],sep="、")
# 写的很好